package com.anpy.album.controller;

import com.anpy.album.entity.AlbumEntity;
import com.anpy.album.service.AlbumService;
import com.anpy.common.service.model.vo.ResponseMessage;
import com.anpy.common.service.model.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/album")
public class AlbumController {
    @Resource
    private AlbumService albumService;

    @PostMapping("/save")
    public ResponseMessage<String> saveClassify(@RequestBody AlbumEntity saveAlbumEntity) {
        boolean saveResponse = albumService.saveAlbum(saveAlbumEntity);
        if (!saveResponse) {
            return Result.error("相册已存在!");
        }
        return Result.success();
    }

    @GetMapping("/list")
    public ResponseMessage<List<AlbumEntity>> list(Integer userId){
       return Result.success(albumService.list(userId));
    }


}
